﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_SZJBXX_DetailManage : System.Web.UI.Page
{
    public int SZID
    {
        get { return Convert.ToInt32(ViewState["_SZID"]); }
        set { ViewState["_SZID"] = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetDrpDownValue();
            SZID = DongDong.Common.Misc.GetQueryStringAsInt("SZID");
            if (SZID != 0)
            {
                PopulateSJZBXXDetail();
            }

        }
    }
    public void PopulateSJZBXXDetail()
    {
        SZJBXX objDet = SZJBXX.GetByID(SZID);
        if (objDet != null)
        {
            txtXing.Text = objDet.Xing;
            txtMing.Text = objDet.Ming;
            txtEngName.Text = objDet.EnglishName;
            txtSex.Text = Enum.GetName(typeof(SZJBXX.sex), objDet.Sex);
            txtBirth.Text = DongDong.Common.Misc.ConvertToShortDateTime(objDet.BirthDate, "yyyy年MM月dd日");
            txtNation.Text = objDet.Nation.ToString();
            txtMinZu.Text = objDet.MingZhu.ToString();
            txtJYCD.Text = Enum.GetName(typeof(SZJBXX.LevelEdu),objDet.JYCD);
            txtMQSF.Text = objDet.MQSF.ToString();
            txtZCDJ.Text = objDet.ZCDJ;
            txtMajor.Text = objDet.Major;
            txtLXGJ.Text = objDet.LXGJID;
            txtSSQ.Text = S_District.GetPName_CName_RNameByPID_CID_RID(objDet.ProvinceID, objDet.CityID, objDet.ReginID);
            txtAddress.Text = objDet.Address;
            txtSFGKXM.Text = Enum.GetName(typeof(SZJBXX.IsOrNot), objDet.YSMC);
            txtSFGKJL.Text = Enum.GetName(typeof(SZJBXX.IsOrNot), objDet.YSJL);
            txtZXLXFS.Text = objDet.ZXLXFS;
            txtEndTime.Text = DongDong.Common.Misc.ConvertToShortDateTime(objDet.EndTime, "yyyy年MM月dd日");
            txtNLRZ.Text = objDet.RZLEVEL;
            drpSZStatus.SelectedValue = objDet.Status.ToString();
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        SZJBXX objSZDet = new SZJBXX();
        GetDrpDownValue();
        SZID = DongDong.Common.Misc.GetQueryStringAsInt("SZID");
        if (SZID != 0)
        {
            objSZDet = SZJBXX.GetByID(SZID);
        }
        if (objSZDet != null)
        {
            objSZDet.Status = DongDong.Common.Misc.ConvertToInt(drpSZStatus.SelectedValue);
            objSZDet.Update();
            DongDong.Common.MessageBox.Show(this, "修改成功");
        }
        else
        {
            //objSZDet.AddTime = System.DateTime.Now;
            //objSZDet.Add();
            //DongDong.Common.MessageBox.ShowAndRedirect(this, "修改成功", "Add.aspx");
            DongDong.Common.MessageBox.Show(this, "修改保存失败！");
        }
    }

    public void GetDrpDownValue()
    {
        drpSZStatus.PopulateFromEnum<SZJBXX.statusSZ>();
        drpSZStatus.DataBind();
    }
}